package ast;

import compiler.OutputFormatter;

public class PrintStatement extends Statement {

    private Variable variable;

    public PrintStatement(Variable variable) {
        setVariable(variable);
    }

    @Override
    public void genC(OutputFormatter of) {
        char c;
        if (variable.getType() == Type.INT)
            c = 'd';
        else
            c = 's';
        of.output("printf(\"%" + c + "\\n\", " + variable.getName() + ")");
        super.genC(of);
    }

    public Variable getVariable() {
        return variable;
    }

    public void setVariable(Variable variable) {
        this.variable = variable;
    }
}
